package org.mspring.mlog.action.admin;

import org.mspring.mlog.entity.Article;
import org.mspring.mlog.service.ArticleService;
import org.mspring.nbee.web.Action;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Gao Youbo
 * @since 2014-12-04 17:59
 */
@Action
@RequestMapping("/admin/article")
public class ArticleAction extends BaseAdminAction {

    private ArticleService articleService;

    @RequestMapping("/list")
    public String list(HttpServletRequest request, HttpServletResponse response, Model model) {
        return "/admin/article/list";
    }

    @RequestMapping("/create")
    public String create(HttpServletRequest request, HttpServletResponse response, Model model) {
        return "/admin/article/create";
    }

    @RequestMapping("/create/do")
    public String doCreate(@ModelAttribute Article article, HttpServletRequest request, HttpServletResponse response, Model model) {
        return "redirect:/admin/article/list";
    }


    @RequestMapping("/edit")
    public String edit(HttpServletRequest request, HttpServletResponse response, Model model) {
        return "/admin/article/edit";
    }


    @RequestMapping("/edit/do")
    public String doEdit(HttpServletRequest request, HttpServletResponse response, Model model) {
        return "redirect:/admin/article/list";
    }

    @Autowired
    public void setArticleService(ArticleService articleService) {
        this.articleService = articleService;
    }
}
